const db = wx.cloud.database()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
  },

  onLoad: function (options) {
    this.getData()
  },

  getData() {
    let that = this
    db.collection("article")
      .where({
        state: true
      })
      .get()
      .then(res => {
        that.setData({
          list: res.data
        })
      })
      .catch(err => {
        console.error('getData()：', err)
      })
  },

  onShowTap(e) {
    let { data } = e.currentTarget.dataset
    data = encodeURIComponent(data)
    wx.navigateTo({
      url: '/pages/article/show?url=' + data
    })
  }
})